package utils;

import cn.hutool.core.util.XmlUtil;
import org.w3c.dom.Document;

import javax.xml.xpath.XPathConstants;
import java.io.File;

/**
 * <?xml version='1.0' encoding='utf-8' ?>
 * <content_list>
 * <programmeID><![CDATA[1343720201013]]></programmeID>
 * <programmetype><![CDATA[0]]></programmetype>
 * <content>
 *
 * <columnid>2994</columnid>
 * <title><![CDATA[目前每日核酸检测人数在四五百人  较之前明显增加]]></title>
 * <channelCName>安徽公共</channelCName>
 * <channelName>AnHuiPublic</channelName>
 * <keywords><![CDATA[核酸检测人数 疫情]]></keywords>
 * <newcontent><![CDATA[]]></newcontent>
 * <source><![CDATA[安徽公共]]></source>
 * <picurl><![CDATA[http://10.30.18.25/xwwbc/2020/10/13/AnHuiPublic_1500000_20201013_36575442_0.jpg]]></picurl>
 * <playTime><![CDATA[2020-10-13 12:16:39]]></playTime>
 * <author>TVM</author>
 * <article_type>3</article_type>
 * <duration>160200</duration>
 * <language>Chinese</language>
 * <uuid>77ac7467-070c-45de-b82c-a6721d3d92ca</uuid>
 * <coloumnName>新闻午班车</coloumnName>
 * <videorate>800K</videorate>
 * <vedio><![CDATA[N8500_35T/Program/xwwbc/2020/10/13/AnHuiPublic_1500000_20201013_36575442_0_265.mp4]]></vedio>
 * </content>
 * </content_list>
 */
public class XMLUtils {
    public static void main(String[] args) {
        Document document = XmlUtil.readXML(new File("D:\\TestVideo\\AnHuiFinance_1500000_20201015_36585228_0_520_1.xml"));
        System.out.println("document = " + document.getTextContent());
        Object value = XmlUtil.getByXPath("//content_list/content/vedio", document, XPathConstants.STRING);
        Object valueNull = XmlUtil.getByXPath("//content_list/content/vedioNull", document, XPathConstants.STRING);
        System.out.println("value = " + value);
        System.out.println("valueNull = " + valueNull);
    }
}
